local zhongshuo = fk.CreateSkill {
  name = "emo__zhongshuo",
}

zhongshuo:addEffect("active", {
  anim_type = "offensive",
  target_num = 1,
  card_num = 0,
  prompt = "#emo__zhongshuo",
  target_filter = function (self, player, to_select, selected)
    return #selected == 0
  end,
  can_use = function (self, player)
    return player:usedSkillTimes(zhongshuo.name, Player.HistoryPhase) == 0
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(zhongshuo.name, Player.HistoryPhase)
  end,
  on_use = function (self, room, use)
    local player, to = use.from, use.tos[1]
    if not to:isNude() and player ~= to then
      local get = table.random(to:getCardIds("he"))
      room:obtainCard(player, get, false, fk.ReasonPrey, player, zhongshuo.name)
    end
    for _, p in ipairs(room:getOtherPlayers(to)) do
      if to.dead then break end
      if not p:isNude() and not p.dead then
        local discard = room:askToDiscard(p, {
          max_num = 1, min_num = 1, include_equip = true, cancelable = true, skill_name = zhongshuo.name, skip = true,
          prompt = "#emo__zhongshuo-discard:"..to.id
        })
        if #discard > 0 then
          local color = Fk:getCardById(discard[1]).color
          room:throwCard(discard, zhongshuo.name, p, p)
          room:doIndicate(p, {to})
          if color == Card.Red and to:isWounded() then
            room:recover({ who = to, num = 1, recoverBy = p, skillName = zhongshuo.name })
          elseif color == Card.Black then
            room:damage { from = p, to = to, damage = 1, skillName = zhongshuo.name }
          end
        end
      end
    end
    if player.dead then return end
    if to.dead then
      player:drawCards(3, zhongshuo.name)
      player:setSkillUseHistory(zhongshuo.name, 0, Player.HistoryPhase)
    end
  end,
})


Fk:loadTranslationTable{
  ["emo__zhongshuo"] = "众铄",
  [":emo__zhongshuo"] = "出牌阶段限一次，你可以获得一名角色的随机一张牌，并令除其以外所有角色依次可以弃置一张牌：若弃置黑色牌，对其造成1点伤害；若弃置红色牌，令其回复1点体力。然后若其死亡，你摸三张牌并视为未发动。",

  ["#emo__zhongshuo"] = "众铄：获得一名角色的一张牌，然后其他角色可以弃牌令其受伤或回血",
  ["#emo__zhongshuo-discard"] = "弃置一张黑色手牌对 %src 造成1点伤害，或弃置一张红色手牌令 %src 回复1点体力",
}

return zhongshuo
